package com.bao.interkont.controller;

import com.bao.interkont.pojo.Comment;
import com.bao.interkont.pojo.Result;
import com.bao.interkont.server.CommentServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author bao*
 * @version 1.0
 */
@RestController
public class CommentController {
    @Autowired
    private CommentServer commentServer;

    @GetMapping("/comments")
    public Result getComment(Integer articleId) {
        return Result.success(commentServer.getComments(articleId));
    }

    @PostMapping("/comments")
    public Result addComment(@RequestBody Comment comment) {
        commentServer.addComment(comment);
        return Result.success();
    }
}
